<%-- 
    Document   : add_user
    Created on : 22.04.2013, 0:04:30
    Author     : Yasya
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jstl/fmt" %>
<!DOCTYPE html>


<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <link rel="stylesheet" type="text/css" href="css/add_edit_user.css">
        <title>Add/Edit user</title>
           <script>
        function deleteProduct() {
            document.getElementById("mainForm").action = "Delete";
            document.getElementById("mainForm").submit();
        }

        function editUser() {
            document.getElementById("mainForm").action = "UpdateUser";
            document.getElementById("mainForm").submit();
        }


    </script>
    </head>
    <body>      
        <header>
            <div id ="top_name"> <h1> User name</h1> </div>
        </header>
        
        <div id="main">
            <div id="label1">
           
          

                <p>First Name:</p>
                <p>Last Name:</p>
                <p>E-mail:</p>
                <p>Address:</p>
                <p>Group:</p>
                <p>Roles:</p>
                             
            </div>
            <div id="correction" Style="margin-top:100px">  
            <form method="Post" action="UpdateUser"> 
                    <c:set var="roles" scope="page" value="${user.getRoleCollection()}"/>
                    <c:set var="groups" scope="page" value="${user.getGroupsCollection()}"/>
                    <input type="hidden" name="idUser" value="${user.getIdUser()}"/>
                    <p> <input type="text" name="First Name" size="50" value="${user.getFirstName()}" /></p>
                    <p> <input type="text" name="Last Name" size="50" value="${user.getLastName()}"/></p>
                    <p>   <input type="text" name="E-mail" size="50"  value="${user.getEMail()}"/></p>
                    <p>  <input type="text" name="Address" size="50" value="${user.getAddress()}"/></p>
                    <p>     <c:if test="${not empty groups}"> 
                                    <select>
                                        <c:forEach var="group" items="${groups}">
                                            <option ><c:out value="${group.getGroupName()}"/></option>
                                        </c:forEach>
                                    </select>
                                 </c:if>
                                  <c:if test="${empty groups}"> None </c:if></p>
                   
                    <p>
                   
                                 <c:if test="${not empty roles}"> 
                                    <select>
                                        <c:forEach var="role" items="${roles}">
                                            <option ><c:out value="${role.getRoleName()}"/></option>
                                        </c:forEach>
                                    </select>
                                 </c:if>
                                  <c:if test="${empty roles}"> None </c:if>
                                  </p>
                <div id="line_button"> <button onclick="editUser()" id="func" type="submit">OK</button></div>
                <div id="line_button"> <form method="post" action="admin.jsp"><button id="func" type="submit" >Delete</button>  </form>  </div>
                <div id="line_button"> <form method="post" action="admin.jsp"> <button id="func" type="submit">Cancel</button> </form> </div>
            
                </form>
            </div>
        </div>
    </body>
</html>